<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <%@ include file="/common/dxp/include/common-base.jsp" %>
    <title>报文格式管理</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>

<!-- Part 一、 以下是body主体内容的模块区域 -->
<body class="hold-transition ${sysColor} sidebar-mini">
<div class="wrapper">

    <!-- top start -->
    <%@include file="/common/dxp/top.jsp" %>
    <!-- top end -->
    <!-- left start -->
    <%@include file="/common/dxp/left.jsp" %>
    <!-- left end-->

    <div class="content-wrapper">
        <!-- Main start -->
        <section class="content">
            <div id="div_hidden_content" class="hidden" style="display:none;">
                <input name="templateType" type="hidden" value="all"/>
                <div id="hidden_common_final">
                    <!-- temp="hidden_common_final" start -->
                    <input name="mainObjName" type="hidden" value="dxMsgFormatSet">
                    <input name="mainObjPrimaryKey" type="hidden" value="infoId">
                    <input name="objNameAll" type="hidden" value="dxMsgFormatSet">
                    <!-- temp="hidden_common_final" end -->
                </div>
                <!-- temp="delForm_hidden" start -->
                <div id="delForm_hidden" style="display:none;">
                    <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                    <input type="hidden" name="formName" value="delForm"/>
                </div>
                <!-- temp="delForm_hidden" end -->
                <form id="searchForm" action="javascript:;">
                    <!-- temp="searchForm_hidden" start -->
                    <div id="searchForm_hidden" style="display:none;">
                        <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                        <input type="hidden" name="formName" value="searchForm"/>
                        <input type="hidden" name="dxMsgFormatSet.w_interfaceId" value="${param.interfaceId}"/>
                        <input type="hidden" name="dxMsgFormatSet.w_msgType" value="${param.msgType}"/>
                        <%--<input type="hidden" name="orderBy" value="dxMsgFormatSet.create_time desc"/>--%>
                    </div>
                    <!-- temp="searchForm_hidden" end -->
                </form>
            </div>
            <div class="row">
                <div class="col-xs-12">


                    <!------- 列表 start -------->
                    <div class="box box-success">
                        <!--列表title  start -->
                        <div class="box-header with-border">
                            <h3 class="box-title"><%--<i class="fa fa-table"></i> 查询结果--%>
                                <button id="button_to_add" onclick="toAdd('parent');" class="btn btn-success"
                                        type="button"><i
                                        class="fa fa-plus-circle"></i> 增加报文
                                </button>
                                <button id="button_to_add_child" onclick="toAdd('child');" class="btn btn-primary"
                                        type="button"><i
                                        class="fa fa-plus-circle"></i> 增加子级报文
                                </button>

                                <button onclick="goBack();" class="btn btn-default btn-xs"
                                        type="button"><i
                                        class="fa fa-reply"></i> 返回上级
                                </button>
                            </h3>
                            <span style="color: #3181ff" >接口编号：<span style="color: red">${param.interfaceCode}；</span>报文格式：<span style="color: red">${param.interfaceRMFT}；</span></span>
                            <div class="box-tools pull-right">
                                <button type="button" class="btn btn-box-tool" data-widget="collapse"><i
                                        class="fa fa-minus"></i></button>
                            </div>
                        </div>
                        <div class="box-body">
                            <table id="dataList" class="table table-bordered table-hover">
                                <thead>
                                <tr id="dataList_thead_content" data-temp-code="true" data-temp-type="table"
                                    data-temp-show="dataList_template_content">
                                    <!-- temp="dataList_thead_content" start -->

<%--                                    <th data-field="interfaceId" data-temp-obj="dxMsgFormatSet.interfaceId">接口Id</th>--%>
                                    <th data-field="paramEname" data-temp-obj="dxMsgFormatSet.paramEname">参数英文名</th>
                                    <th data-field="paramCname" data-temp-obj="dxMsgFormatSet.paramCname">参数中文名</th>
                                    <th data-field="paramType" data-formatter="paramTypeFormatter">参数类型</th>
                                    <th data-field="cloumEname" data-temp-obj="dxMsgFormatSet.cloumEname">映射参数英文名</th>
<%--                                    <th data-field="interfaceCode" data-temp-obj="dxMsgFormatSet.interfaceCode">接口编号</th>--%>
<%--                                    <th data-field="interfaceRMFT" data-temp-obj="dxMsgFormatSet.interfaceRMFT">接口报文格式</th>--%>
<%--                                    <th data-field="ifSubParam" data-formatter="yesOrNoFormatter">是否有下级</th>--%>
<%--                                    <th data-field="ifNull" data-formatter="yesOrNoFormatter">是否允许为空</th>--%>
                                    <th data-field="infoId" data-formatter="statusFormatter">操作</th>
                                    <!-- temp="dataList_thead_content" end -->
                                </tr>
                                </thead>
                                <tbody id="dataList-body">

                                </tbody>
                            </table>
                        </div>

                        <div class="box-footer text-center">
                            <ul id="dataList-page" class="pagination">
                            </ul>
                        </div>
                    </div>
                    <!------- 列表 end -------->
                </div>
            </div>

            <div win-title="添加窗口" class="modal fade" id="my_modal_add" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:40%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">信息添加</font> 
                            </h4>
                        </div>

                        <div class="modal-body">

                            <div class="nav-tabs-custom">
                                <ul class="nav nav-tabs" id="myTab-add">
                                </ul>

                                <!-- tab content start -->
                                <div class="tab-content">

                                    <div class="tab-pane active" id="tabAdd_1">
                                        <form class="form-horizontal addFormBody" role="form" id="addForm1"
                                              action="javascript:void(0)">
                                            <input type="hidden" class="formToken" id="addForm1_formToken"
                                                   name="formToken"/>
                                            <input type="hidden" name="dxMsgFormatSet.paramParent" class="clean"/>
                                            <input type="hidden" name="dxMsgFormatSet.interfaceId" value="${param.interfaceId}"/>
                                            <input type="hidden" name="dxMsgFormatSet.interfaceCode" value="${param.interfaceCode}"/>
                                            <input type="hidden" name="dxMsgFormatSet.interfaceRMFT" value="${param.interfaceRMFT}"/>
                                            <input type="hidden" name="dxMsgFormatSet.msgType" value="${param.msgType}"/>
                                            <input type="hidden" name="dxMsgFormatSet.ifSubParam" value="0"/>
                                            <!-- temp="addForm1_hidden" start -->
                                            <div id="addForm1_hidden" style="display:none;">
                                                <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                                                <input type="hidden" name="formName" value="addForm"/>
                                            </div>
                                            <!-- temp="addForm1_hidden" end -->

                                            <!-- temp="addForm1_content" start -->
                                            <div id="addForm1_content" data-temp-code="true" data-temp-type="addForm"
                                                 data-temp-form-id="addForm1">


                                                <table class="table table-bordered bordercolor">
                                                    <tbody>
                                                    <tr id="addForm1_dxMsgFormatSet_interfaceId_tr">
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">接口编号：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span>${param.interfaceCode}</span></div>
                                                        </td>
                                                    </tr>
                                                    <tr id="addForm1_dxMsgFormatSet_paramParent_tr"
                                                        style="display:none;">
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">上级参数：</label></td>
                                                        <td>
                                                            <div class="form-control-static">
                                                                <span id="addForm1_dxMsgFormatSet_paramParent"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.cloumEname"
                                                                    class="form-control clean" maxlength="30"
                                                                    data-temp-obj="dxMsgFormatSet.cloumEname"
                                                                    onchange="setdataShortName(this,'addForm1')"
                                                                    placeholder="只能字母" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数中文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramCname"
                                                                    class="form-control clean" maxlength="30"
                                                                    data-temp-obj="dxMsgFormatSet.paramCname"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数类型：</label></td>
                                                        <td>
                                                            <div class="form-group"><select
                                                                    id="addForm1_dxMsgFormatSet_paramType"
                                                                    name="dxMsgFormatSet.paramType"
                                                                    class="form-control  clean"
                                                                    data-temp-obj="dxMsgFormatSet.paramType"
                                                                    data-dict-code="dictItemList"
                                                                    data-dict-cate="paramType" data-type-tag="select"
                                                                    data-def=""
                                                                    placeholder="必填项" data-bv-notempty="true" data-bv-notempty-message="不能为空">
                                                                <option value="">--请选择--</option>
                                                            </select></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">映射参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramEname"
                                                                    class="form-control clean" maxlength="30"
                                                                    data-temp-obj="dxMsgFormatSet.paramEname"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">是否允许为空：</label></td>
                                                        <td>
                                                            <div class="form-group">
                                                                <div class="form-control-static"
                                                                     id="addForm1_dxMsgFormatSet_ifNull"
                                                                     name="dxMsgFormatSet.ifNull"
                                                                     data-temp-obj="dxMsgFormatSet.ifNull"
                                                                     data-dict-code="dictItemList"
                                                                     data-dict-cate="enabled" data-colmun=""
                                                                     data-condition="" data-type-tag="radio"
                                                                     data-def="1">[radio]
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                    </tbody>
                                                </table>

                                            </div>
                                            <!-- temp="addForm1_content" end -->


                                            <div class="form-group">
                                                <div class="col-sm-12">
                                                    <div class="box-footer text-center">
                                                        <button class="btn btn-success pull-left" type="button"
                                                                onclick="mytools.closeModal('my_modal_add');"> 取消
                                                        </button>
                                                        <button class="btn btn-danger pull-right" type="button"
                                                                onclick="submitForm1('addForm1','');"
                                                                data-temp-event="addForm1_hidden"> 提 交
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>

                                        </form>
                                    </div>

                                </div>
                                <!-- tab content e -->
                            </div>

                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>

            <div win-title="修改窗口" class="modal fade" id="my_modal_edit" tabindex="-1" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:40%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">信息修改</font> 
                            </h4>
                        </div>
                        <div class="modal-body">
                            <div class="nav-tabs-custom">
                                <ul class="nav nav-tabs" id="myTab-edit">
                                </ul>

                                <!-- tab content start -->
                                <div class="tab-content">

                                    <div class="tab-pane active" id="tabEdit_1">
                                        <form class="form-horizontal editFormBody" role="form" id="editForm1"
                                              action="javascript:void(0)">
                                            <input type="hidden" class="formToken" id="editForm1_formToken"
                                                   name="formToken"/>
                                            <!-- temp="editForm1_hidden" start -->
                                            <div id="editForm1_hidden">
                                                <input type="hidden" name="pageName" value="dx-msg-format-set"/>
                                                <input type="hidden" name="formName" value="editForm"/>
                                                <input type="hidden" name="dxMsgFormatSet.w_infoId" data-name="dxMsgFormatSet.infoId" class="clean"/>
                                            </div>
                                            <!-- temp="editForm1_hidden" end -->

                                            <!-- temp="editForm1_content" start -->
                                            <div id="editForm1_content">


                                                <table class="table table-bordered bordercolor">
                                                    <tbody>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    data-name="dxMsgFormatSet.cloumEname"></span></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数中文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramCname"
                                                                    class="form-control clean" maxlength="30"
                                                                    data-temp-obj="dxMsgFormatSet.paramCname"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"
                                                                    data-name="dxMsgFormatSet.paramCname"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数类型：</label></td>
                                                        <td>
                                                            <div class="form-group"><select
                                                                    id="editForm1_dxMsgFormatSet_paramType"
                                                                    name="dxMsgFormatSet.paramType"
                                                                    class="form-control  clean"
                                                                    data-temp-obj="dxMsgFormatSet.paramType"
                                                                    data-dict-code="dictItemList"
                                                                    data-dict-cate="paramType" data-type-tag="select"
                                                                    data-def="" data-name="dxMsgFormatSet.paramType"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空">
                                                                <option value="">--请选择--</option>
                                                            </select></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">映射参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-group"><input
                                                                    name="dxMsgFormatSet.paramEname"
                                                                    class="form-control clean" maxlength="30"
                                                                    data-temp-obj="dxMsgFormatSet.paramEname"
                                                                    data-name="dxMsgFormatSet.paramEname"
                                                                    placeholder="必填项" data-bv-notempty="true"
                                                                    data-bv-notempty-message="不能为空"></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">是否允许为空：</label></td>
                                                        <td>
                                                            <div class="form-group">
                                                                <div class="form-control-static"
                                                                     id="editForm1_dxMsgFormatSet_ifNull"
                                                                     name="dxMsgFormatSet.ifNull"
                                                                     data-temp-obj="dxMsgFormatSet.ifNull"
                                                                     data-dict-code="dictItemList"
                                                                     data-dict-cate="enabled" data-colmun=""
                                                                     data-condition="" data-type-tag="radio" data-def="T"
                                                                     data-name="dxMsgFormatSet.ifNull">[radio]
                                                                </div>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                    </tbody>
                                                </table>

                                            </div>
                                            <!-- temp="editForm1_content" end -->

                                            <div class="form-group">
                                                <div class="col-sm-12">
                                                    <div class="box-footer text-center">
                                                        <button class="btn btn-success pull-left" type="button"
                                                                onclick="mytools.closeModal('my_modal_edit');"> 取消
                                                        </button>
                                                        <button class="btn btn-danger pull-right" type="button"
                                                                onclick="submitForm1('editForm1','');"
                                                                data-temp-event="editForm1_hidden"> 提 交
                                                        </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                    </div>

                                </div>
                                <!-- tab content e -->
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>

            <div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:40%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">查看详情</font> 
                            </h4>
                            <form id="viewForm" action="javascript:void(0)">
                                <!-- temp="viewForm_hidden" start -->
                                <div id="viewForm_hidden" style="display:none;"></div>
                                <!-- temp="viewForm_hidden" end -->
                            </form>
                        </div>
                        <div class="modal-body viewForm">

                            <div class="nav-tabs-custom">
                                <ul class="nav nav-tabs" id="myTab-view">
                                </ul>

                                <!-- tab content start -->
                                <div class="tab-content">

                                    <div class="tab-pane active" id="tabView_1">
                                        <form class="form-horizontal" role="form" id="viewForm1"
                                              action="javascript:void(0)">

                                            <!-- temp="viewForm1_content" start -->
                                            <div id="viewForm1_content" class="row viewForm">


                                                <table class="table table-bordered bordercolor">
                                                    <tbody>
                                                    <tr id="viewForm1_dxMsgFormatSet_interfaceId_tr" style="">
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">接口编号：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    data-name="dxMsgFormatSet.interfaceCode"
                                                                    ></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr id="viewForm1_dxMsgFormatSet_paramParent_tr"
                                                        style="display:none;">
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">上级参数：</label></td>
                                                        <td>
                                                            <div class="form-control-static">
                                                                <span id="viewForm1_dxMsgFormatSet_paramParent"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    data-name="dxMsgFormatSet.cloumEname"></span></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数中文名：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    data-name="dxMsgFormatSet.paramCname"></span></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">参数类型：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    id="viewForm1_dxMsgFormatSet_paramType"
                                                                    data-dict-cate="paramType"
                                                                    data-dict-code="dictItemList" data-type-tag="select"
                                                                    data-name="dxMsgFormatSet.paramType"
                                                                    data-dict="paramType"></span></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">映射参数英文名：</label></td>
                                                        <td>
                                                            <div class="form-control-static"><span
                                                                    data-name="dxMsgFormatSet.paramEname"></span></div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">是否有下级：</label></td>
                                                        <td>
                                                            <div class="form-control-static">
                                                                <span id="viewForm1_dxMsgFormatSet_ifSubParam"
                                                                      data-dict-cate="enabled"
                                                                      data-dict-code="dictItemList"
                                                                      data-type-tag="radio"
                                                                      data-name="dxMsgFormatSet.ifSubParam"
                                                                      data-dict="enabled"></span>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="active" align="right"><label
                                                                class="form-control-static">是否允许为空：</label></td>
                                                        <td>
                                                            <div class="form-control-static">
                                                                <span id="viewForm1_dxMsgFormatSet_ifNull"
                                                                      data-dict-cate="enabled"
                                                                      data-dict-code="dictItemList"
                                                                      data-type-tag="radio"
                                                                      data-name="dxMsgFormatSet.ifNull"
                                                                      data-dict="enabled"></span>
                                                            </div>
                                                        </td>
                                                    </tr>

                                                    </tbody>
                                                </table>

                                            </div>
                                            <!-- temp="viewForm1_content" end -->

                                        </form>
                                        <div class="form-group">
                                            <div class="col-sm-12">
                                                <div class="box-footer text-center">
                                                    <button class="btn btn-success pull-right" type="button"
                                                            onclick="mytools.closeModal('my_modal_view');"> 关闭
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                                <!-- tab content e -->
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>
            <div win-title="查看报文格式窗口" class="modal fade" id="my_modal_msg_format_view" tabindex="-2" role="dialog"
                 aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width:60%;">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                ×
                            </button>
                            <h4 class="modal-title">
                                <font color="red">报文格式</font>
                            </h4>
                        </div>
                        <div class="modal-body viewForm">

                            <div class="nav-tabs-custom">

                                <!-- tab content start -->
                                <div class="tab-content">

                                    <div class="tab-pane active" id="tabMsgFormatView_1">
                                        <form class="form-horizontal" role="form" id="viewMsgFormatForm1"
                                              action="javascript:void(0)">

                                            <!-- temp="viewForm1_content" start -->
                                            <div id="viewMsgFormatForm1_content" class="row viewForm">
                                                <table class="table table-bordered bordercolor">
                                                    <tbody >
                                                    <tr>
                                                        <td >
                                                            <div class="form-control-static">
                                                                <pre style="height: 260px; overflow-y: scroll;"><code id="viewForm1_msg_form_json"></code></pre>
                                                            </div>
                                                        </td>

                                                    </tr>

                                                    </tbody>
                                                </table>
                                            </div>
                                            <!-- temp="viewForm1_content" end -->

                                        </form>
                                        <div class="form-group">
                                            <div class="col-sm-12">
                                                <div class="box-footer text-center">
                                                    <button class="btn btn-success pull-right" type="button"
                                                            onclick="mytools.closeModal('my_modal_msg_format_view');"> 关闭
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>


                                </div>
                                <!-- tab content e -->
                            </div>
                        </div>
                    </div>
                    <!-- /.modal-content -->
                </div>
            </div>

            <!-- Part 二、以下是template模板定义的模块区域 -->

            <!-- Part 三、 以下是js模块区域 -->
            <script>
                var clickMenu = "msg-format-list";
                var myPage, dataListId, searchFormId;
                myPage = 10;//定义列表数据
                dataListId = "dataList";//显示列表数据div的id
                searchFormId = "searchForm";//搜索表单Id

                var selected_id, selected_paramEname, selected_interfaceId, selected_interfaceCode,selected_ifSubParam,selected_parentId,selected_interfaceRMFT;
                var levelType="";
                var selected_nodes=[];
                /**
                 * 初始化数据字典，id传入#id 返回值Map用法：dictListMap["userType"][rows[i].userType]
                 */
                var dictListMap = DictUtil.initDictAndDymic();
                var $table = $('#' + dataListId);
                $(function () {
                    //1、加载分页列表数据
                    getTableData();

                    //2、控制是否启用token
                    //setToken();

                });

                //注入日历框样式
                var dateObject = $('.datepicker').datepicker({
                    language: 'zh-CN',
                    //inline: true,
                    todayBtn: "linked",
                    format: "yyyy-mm-dd",
                    autoclose: true
                }).on('hide', function (e) {
                    //bootstrap datepicker与bootstrapValidator同时使用时选择日期后无法正常触发校验的解决方法
                    //当日期选择框关闭时，执行刷新校验。
                    var fieldName = $(this).attr("name");//获取当前元素name
                    var formId = $(this).parents("form").eq(0).attr("id");//获取当前元素所在父层级中的就近的formId
                    $("#" + formId).data('bootstrapValidator').updateStatus(fieldName, 'NOT_VALIDATED', null).validateField(fieldName);
                });

                //给模态窗口内form表单内的所有支持必填项的元素注入校验
                $(".modal").on('shown.bs.modal', function () {
                    $(this).find("form").each(function () {
                        var formId = $(this).attr("id");
                        if (!strUtil.isNull(formId)) {
                            formId = "#" + formId;
                            setValidate(formId);//定义add表单验证属性
                            mytools.cleanValidate(formId);//清空上次校验规则提示
                        }
                    });
                });

                //打开添加modal
                function toAdd(val) {
                    levelType=val;
                    mytools.cleanData(".addFormBody");//清空表单元素上次填写的内容；
                    $(".datepicker").val("");
                    if (val == 'child') {
                        if (selected_id == "undefined" || selected_id == "" || selected_id == null) {
                            layer.alert('请先选中一条数据！', {closeBtn: 0});
                            return;
                        } else {
                            $("#addForm1_dxMsgFormatSet_paramParent_tr").show();
                            $("#addForm1").find("input[name='dxMsgFormatSet.interfaceId']").val(selected_interfaceId);
                            $("#addForm1").find("input[name='dxMsgFormatSet.interfaceCode']").val(selected_interfaceCode);
                            $("#addForm1").find("input[name='dxMsgFormatSet.paramParent']").val(selected_id);
                            $("#addForm1").find("input[name='dxMsgFormatSet.interfaceRMFT']").val(selected_interfaceRMFT);
                            $("#addForm1_dxMsgFormatSet_paramParent").text(selected_paramEname);
                        }
                        $("#addForm1").find("input").attr("readonly",false);
                    } else if (val == 'parent') {
                        var flag = checkInterface();
                        if(flag){
                            layer.msg('此接口报文已存在根节点，请直接添加子节点！');
                            return;
                        }
                        selected_nodes=[];
                        $("#addForm1_dxMsgFormatSet_interfaceId_tr").show();
                        $("#addForm1_dxMsgFormatSet_paramParent_tr").hide();
                        $("#addForm1").find("input[name='dxMsgFormatSet.paramParent']").val("0");
                        if('json'=='${param.interfaceRMFT}'){
                            $("#addForm1").find("input[name='dxMsgFormatSet.cloumEname']").val("defaultRoot");
                            $("#addForm1").find("input[name='dxMsgFormatSet.paramCname']").val("默认根节点");
                            $("#addForm1").find("input[name='dxMsgFormatSet.paramEname']").val("defaultRoot");
                            $("#addForm1").find("input[name='dxMsgFormatSet.paramType']").val("2");
                            $("#addForm1").find("input[name='dxMsgFormatSet.paramType']").text("字符串");
                            $("#addForm1").find("input").attr("readonly",true);
                        }
                        $("#addForm1_dxMsgFormatSet_paramParent").text("无");

                    }
                    $("#my_modal_add").modal("show");
                }

                //数据toLoad读取（查看、编辑）数据
                function toLoad(obj, type) {
                    if ("view" == type) {
                        $("#my_modal_view").modal("show");
                    } else if ("edit" == type) {
                        mytools.cleanData(".editFormBody");//清空表单元素上次填写的内容；
                        $("#my_modal_edit").modal("show");
                    }
                    var paramLoadData = {};
                    paramLoadData["pageName"] = $("#searchForm").find("input[name='pageName']").val();
                    paramLoadData["formName"] = $("#searchForm").find("input[name='formName']").val();
                    paramLoadData["dxMsgFormatSet.w_infoId"] = obj;
                    $.get(common_info_url, paramLoadData, function (myData) {
                        // console.log(myData,"fpc---view");
                        //反显加载数据
                        if (myData) {
                            var myDataNew = {dxMsgFormatSet:myData};
                            for (var objNameKey in myDataNew) {
                                console.log(objNameKey,"objNameKey");
                                console.log(myDataNew,"myDataNew");
                                FormUtil.loadView(objNameKey, myDataNew[objNameKey], "#my_modal_" + type);
                            }
                        }
                    }, "json");
                }

                function changeInterface(obj) {
                    var option = $(obj).find("option:selected");
                    // console.log(option,"obj");
                    var value = option.val();
                    //校验此接口有没有添加报文
                    var paramLoadData={};
                    paramLoadData["pageName"] = $("#searchForm").find("input[name='pageName']").val();
                    paramLoadData["formName"] = $("#searchForm").find("input[name='formName']").val();
                    paramLoadData["dxMsgFormatSet.w_interfaceId"] = value;
                    $.get(common_list_url, paramLoadData, function (myData) {
                        // console.log(myData,"myData");
                        if(myData.rows.length>0){
                            layer.tips('此接口报文已存在，请更换接口！', '#addForm1_dxMsgFormatSet_interfaceId', {tips: 3});
                            // layer.alert("此接口已添加报文，不能重复添加");
                            $("#addForm1_dxMsgFormatSet_interfaceId").val("");
                            return;
                        }
                    }, "json");
                    // var text = option.text();
                    var reqMsgFormatType = option.attr("req-msg-format-type");
                    var interfaceCode = option.attr("interface-code");
                    if (value) {
                        $("#addForm1").find("input[name='dxMsgFormatSet.interfaceId']").val(value);
                        $("#addForm1").find("input[name='dxMsgFormatSet.interfaceCode']").val(interfaceCode);
                        $("#addForm1").find("input[name='dxMsgFormatSet.interfaceRMFT']").val(reqMsgFormatType);
                    }
                }

                function checkInterface() {
                    var flag=false;
                    var paramLoadData={};
                    paramLoadData["pageName"] = $("#searchForm").find("input[name='pageName']").val();
                    paramLoadData["formName"] = $("#searchForm").find("input[name='formName']").val();
                    paramLoadData["dxMsgFormatSet.w_interfaceId"] = '${param.interfaceId}';
                    paramLoadData["dxMsgFormatSet.w_msgType"] = '${param.msgType}';
                    paramLoadData["dxMsgFormatSet.w_paramParent"] ="0";
                    $.ajaxSettings.async = false;
                    $.get(common_list_url, paramLoadData, function (myData) {
                        // console.log(myData,"myData");
                        if(myData.rows.length>0){
                            layer.msg('此接口报文已存在根节点，请直接添加子节点！');
                            // layer.alert("此接口已添加报文，不能重复添加");
                            flag=true;
                        }
                    }, "json");
                    $.ajaxSettings.async = true;
                    return flag;
                }

                //删除调用
                function toDele(value,nodesLength,brothersLength,parentId) {
                    // console.log("nodesLength-->"+nodesLength+"-----brothersLength-->"+brothersLength);
                    if(nodesLength>0){
                        layer.alert("此参数节点下有子级参数，请先删除子级参数。");
                        return;
                    }
                    if (!$("#delForm_hidden").find("input[name='formName']").val()) {
                        layer.alert("缺失删除参数！");
                        return;
                    }
                    var index_submit = layer.confirm("您确定要删除信息吗？", {btn: ["Yes", "No"], closeBtn: 0, offset: "220px"}
                        , function () {
                            layer.close(index_submit);
                            var paramData = {};
                            paramData["pageName"] = $("#delForm_hidden").find("input[name='pageName']").val();
                            paramData["formName"] = $("#delForm_hidden").find("input[name='formName']").val();
                            paramData["dxMsgFormatSet.w_infoId"] = value;
                            $.ajax({
                                type: "post",
                                url: common_submit_url,
                                data: paramData, dataType: "json",
                                success: function (myData) {
                                    var result = myData.flag;
                                    if (result == "T") {
                                        if(brothersLength==1){
                                            updateIfSubParam(parentId,"0");
                                        }
                                        refresh();
                                    } else {
                                        layer.alert("删除失败！");
                                    }
                                }
                            });
                        });
                }

                //加载列表数据
                function getTableData(type) {
                    if (strUtil.isNull($("#" + searchFormId).find("input[name='pageName']").val())) {
                        return;
                    }

                    $table.bootstrapTable('destroy');
                    var index_load = layer.load(1, {shade: false});
                    $table.bootstrapTable({
                        url: common_list_url + '?' + $('#searchForm').serialize(),
                        idField: 'infoId',
                        treeShowField: 'paramEname',//在哪一列展开树形
                        parentIdField: 'paramParent',//指定父id列
                        onClickRow: function (row, $element, field) {
                            $element.addClass('selected').siblings().removeClass('selected');
                            selection(row);
                        },
                        onLoadSuccess: function (data) {//加载成功时执行
                            $table.treegrid({
                                initialState: type ? 'expanded' : 'collapsed',// collapsed=所有节点都折叠，'expanded'=所有节点都展开，默认展开
                                // treeColumn: 1,
                                expanderExpandedClass: 'fa fa-caret-down',  //图标样式
                                expanderCollapsedClass: 'fa fa-caret-right',
                                onChange: function () {
                                    $table.bootstrapTable('resetWidth');
                                }
                            });
                            layer.close(index_load);
                            //$table.treegrid('getRootNodes').treegrid('expand');//只展开树形的第一级节点
                            // layer.close(index_load);
                        }
                    });
                }

                //选中效果
                function selection(data) {
                    console.log(data,"data");
                    selected_id = data.infoId;
                    selected_paramEname = data.paramEname;
                    selected_interfaceId = data.interfaceId;
                    selected_interfaceCode = data.interfaceCode;
                    selected_ifSubParam = data.ifSubParam;
                    selected_interfaceRMFT = data.interfaceRMFT;
                    selected_nodes=data._nodes;
                }


                //提交tab1表单数据
                function submitForm1(formId, tabId) {
                    //校验规则-表单提交时触发
                    var validate = $('#' + formId).data('bootstrapValidator').validate();
                    if (!validate.isValid()) { //如果校验不通过就返回
                        return;
                    }
                    if("json"==selected_interfaceRMFT){
                        if(selected_nodes.length>0&&levelType=="child"){
                            var paramEname = $("#addForm1").find("input[name='dxMsgFormatSet.paramEname']").val();
                            for(var i = 0;i<selected_nodes.length;i++){
                                if(selected_nodes[i].paramEname == paramEname){
                                    layer.alert("此接口编号已经存在");
                                    return;
                                }
                            }
                        }
                    }


                    var index_submit = layer.confirm('您确定要保存信息吗？', {btn: ['Yes', 'No'], closeBtn: 0, offset: '220px'}
                        , function () {
                            var result = submitForm(formId, tabId);
                            if (result) {
                                if(levelType=="child"&&"addForm1"==formId){
                                    console.log("selected_ifSubParam",selected_ifSubParam);
                                    if("T"!=selected_ifSubParam){
                                        updateIfSubParam(selected_id,"1")
                                    }
                                }
                                layer.alert("提交成功！", {closeBtn: 0});
                                mytools.closeModal("my_modal_add");
                                mytools.closeModal("my_modal_edit");
                                refresh();


                                setToken();
                                if (!strUtil.isNull(tabId)) {
                                    $('.nav-tabs a[href=\"#' + tabId + '\"]').tab('show'); // Select tab by name
                                }
                            }
                        });

                }
                function updateIfSubParam(infoId,value) {
                    $.ajax({
                        type: 'post',
                        url: common_submit_url,
                        data: {"pageName":"dx-msg-format-set","formName":"editForm","dxMsgFormatSet.w_infoId":infoId,"dxMsgFormatSet.ifSubParam":value},
                        async: false,
                        dataType: 'json',
                        success: function (myData) {
                            console.log(myData);
                            if (myData.flag == "T") {
                                result = myData;
                            }
                        },
                        error: function (e) {
                        }
                    });
                }

                //提交表单数据
                function submitForm(formId, tabId) {
                    var result;
                    var index_load = layer.load(1, {shade: false});
                    $.ajax({
                        type: 'post',
                        url: common_submit_url,
                        data: $("#" + formId).serialize(),
                        async: false,
                        dataType: 'json',
                        success: function (myData) {
                            console.log(myData);
                            if (myData.flag == "T") {
                                result = myData;
                            } else {
                                setToken();
                                layer.alert(myData.msg);
                            }
                            layer.close(index_load);
                        },
                        error: function (e) {
                            layer.close(index_load);
                        }
                    });
                    return result;
                }
                function setdataShortName(obj,formId) {
                    var val = $(obj).val();
                    $("#"+formId).find("input[name='dxMsgFormatSet.paramEname']").val(val);
                }

                function yesOrNoFormatter(value, row, index) {
                    var flag = "否";
                    if("T"==value||"1"==value){
                        flag = "是";
                    }
                    return flag;
                }
                function paramTypeFormatter(value, row, index) {
                    var test = "_";
                    if("1"==value){
                        test = "数字";
                    }else if("2"==value){
                        test = "字符串";
                    }
                    return test;
                }

                //操作按钮
                function statusFormatter(value, row, index){
                    var brothersLength="";
                    var childLength=row._nodes.length;
                    var parentId="";
                    var seeMsgFormat="";
                    if(row._parent){
                        brothersLength = row._parent._nodes.length;
                        parentId = row._parent.infoId;
                    }else {
                        seeMsgFormat = "<button type=\"button\" class=\"btn btn-info btn-xs\" onclick=\"toSeeMsgFormat('"+row.interfaceId+"','"+row.interfaceRMFT+"','"+childLength+"')\"><i class=\"fa fa-search-plus\"></i> 查看报文格式</button>&nbsp;"
                    }
                    var optHtml = "<button type=\"button\" class=\"btn btn-success btn-xs\" onclick=\"toLoad('"+value+"','view')\"><i class=\"fa fa-search-plus\"></i> 查看</button>&nbsp;"+
                        "<button type=\"button\" class=\"btn btn-warning btn-xs\" onclick=\"toLoad('"+value+"','edit');\"><i class=\"fa fa-edit\"></i> 修改</button>&nbsp;"+
                        "<button type=\"button\" class=\"btn btn-danger btn-xs\" onclick=\"toDele('"+value+"','"+row._nodes.length+"','"+brothersLength+"','"+parentId+"');\"><i class=\"fa fa-trash-o\"></i> 删除</button>&nbsp;";
                    optHtml = optHtml+seeMsgFormat;
                    return optHtml;
                }

                //刷新
                function refresh() {
                    selected_id = "";
                    selected_paramEname = "";
                    selected_interfaceId = "";
                    selected_interfaceCode = "";
                    selected_ifSubParam = "";
                    selected_nodes=[];
                    getTableData();
                }
                function toSeeMsgFormat(interfaceId,interfaceRMFT,childLength) {
                    var flag= false;
                    if("json"==interfaceRMFT){
                        if(childLength>0){
                            flag=true;
                        }else{
                            layer.msg("请添加子节点后,再查看报文格式");
                            return;
                        }
                    }else{
                        flag=true;
                    }
                    if(flag){
                        var paramLoadData={};
                        paramLoadData["pageName"] = "dx-msg-format-set-search";
                        paramLoadData["formName"] = "searchForm";
                        paramLoadData["interfaceId"] = interfaceId;
                        paramLoadData["msgFormatType"] = interfaceRMFT;
                        paramLoadData["msgType"] = "${param.msgType}";
                        $.get(common_info_url, paramLoadData, function (myData) {
                            // console.log(myData,"myData");
                            if(myData.result=="T"){
                                // var htm = HTMLEncode(JSON.stringify(myData.entity));
                                // var htm = "<div><span style='color: black'>" + myData.msg+ "</span></div>";
                                // "<div><span>分类错误数据：</span><span style='color:red;'>" + errProCount + "</span></div>";
                                if("json"==interfaceRMFT){
                                    mytools.showJsonViewer(myData.entity,"viewForm1_msg_form_json");
                                }else{
                                    mytools.showXmlFormat("viewForm1_msg_form_json",myData.entity);
                                }
                                $("#my_modal_msg_format_view").modal("show");
                            }else{
                                layer.msg(myData.entity);
                            }
                        }, "json");
                    }
                }
                function HTMLEncode(html) {
                    var temp = document.createElement("div");
                    // console.dir(temp);
                    (temp.textContent != null) ? (temp.textContent = html) : (temp.innerText = html);
                    var output = temp.innerHTML;
                    temp = null;
                    return output;
                }

                //设置token
                function setToken() {
                    $.ajax({
                        type: 'get',
                        url: '${ctx}/sendPage/token?token=true',
                        dataType: 'text',
                        success: function (myData) {
                            console.log(myData);
                            $('.formToken').val(myData);
                        }
                    });
                }
                function goBack() {
                    window.location.href=ctx+"/sendPage/dxp/admin/conf/msg-format-list";
                }

                /**** Part 四、以下是自定义新增方法  ****/
//1.定义校验规则-定义
                function setValidate(id) {
                    $(id).each(function () {
                        $(this).bootstrapValidator({
                            feedbackIcons: {
                                valid: 'glyphicon glyphicon-ok',
                                invalid: 'glyphicon glyphicon-remove',
                                validating: 'glyphicon glyphicon-refresh'
                            }, /** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
                            fields: {
                                /** 可自定义新增验证规则**/
                                 "dxMsgFormatSet.cloumEname":{
                                     validators: {
                                         regexp: {
                                             regexp: /^[a-zA-Z\-_.]+$/,
                                              message: '只能是字母'
                                          }
                                      }
                                }

                            }
                        });
                    });
                }
                // function setdataShortName(formId) {
                //     var dataShortName = $("#"+formId).find("input[name='dxMsgFormatSet.cloumEname']").val();
                //     console.log(dataShortName,"fpc");
                //     if (/^[a-z][a-z0-9_]*$/.test(dataShortName)) {
                //         // $("#dataAttr").val(transformStr3(dataShortName));
                //     } else {
                //         // layer.tips('只能小写字母、数字、下划线组合，且开头必须是字母', '#dataShortName', {tips: 3});
                //         $("#dataShortName").val("");
                //         return;
                //     }
                // }


            </script>
        </section>
        <!-- Main end -->
    </div>
    <!-- foot start -->
    <%@include file="/common/dxp/foot.jsp" %>
    <!-- foot start -->
</div>
<!-- /.content-wrapper -->
</body>
</html>















